import api from "../api.js" //先导入封装好的

// 商品列表
const goods = async (param) => {
	let data = await api.api({
		url: "/jeecg-boot/api/adopt/goods",
		// method: "POST",
		data: param
	})
	return data
}
// 商品详情
const goodsInfo = async (param) => {
	let data = await api.api({
		url: "/jeecg-boot/api/adopt/goods/" + param,
		// method: "POST",
		// data: param
	})
	return data
}
// 购物车列表
const cart = async (param) => {
	let data = await api.api({
		url: "/jeecg-boot/api/adopt/cart",
		// method: "POST",
		data: param
	})
	return data
}
// 添加购物车
const addCart = async (param) => {
	let data = await api.api({
		url: "/jeecg-boot/api/adopt/cart",
		method: "POST",
		data: param
	})
	return data
}
// 修改购物车
const updateCart = async (param) => {
	let data = await api.api({
		url: "/jeecg-boot/api/adopt/cart",
		method: "PUT",
		data: param
	})
	return data
}
// 删除购物车
const deleteCart = async (param) => {
	let data = await api.api({
		url: "/jeecg-boot/api/adopt/cart/" + param,
		method: "DELETE",
		type: "application/x-www-form-urlencoded"
	})
	return data
}
// 商品预下单
const pay = async (param) => {
	let data = await api.api({
		url: "/jeecg-boot/api/adopt/goods/pay",
		method: "POST",
		data: param
	})
	return data
}
// 待付款订单立即付款
const immediately = async (param) => {
	let data = await api.api({
		url: "/jeecg-boot/api/adopt/goods/pay/immediately",
		method: "POST",
		data: param
	})
	return data
}
// 商品再次购买
const repeat = async (param) => {
	let data = await api.api({
		url: "/jeecg-boot/api/adopt/goods/pay/repeat",
		method: "POST",
		data: param
	})
	return data
}
// 商品订单列表
const orderList = async (param) => {
	let data = await api.api({
		url: "/jeecg-boot/api/adopt/goods/order/list",
		// method: "POST",
		data: param
	})
	return data
}
// 商品订单详情
const orderDetail = async (param) => {
	let data = await api.api({
		url: "/jeecg-boot/api/adopt/goods/order/detail/" + param,
		method: "GET"
	})
	return data
}
// 商品订单取消原因列表
const cancelReasons = async (param) => {
	let data = await api.api({
		url: "/jeecg-boot/api/adopt/goods/order/cancel/reasons",
		method: "GET",
		data: param
	})
	return data
}
// 商品订单取消
const orderCancel = async (param) => {
	let data = await api.api({
		url: "/jeecg-boot/api/adopt/goods/order/cancel",
		method: "POST",
		data: param
	})
	return data
}
// 商品订单评价
const evaluate = async (param) => {
	let data = await api.api({
		url: "/jeecg-boot/api/adopt/goods/order/evaluate",
		method: "POST",
		data: param
	})
	return data
}
// 商品订单评价
const evaluateId = async (param) => {
	let data = await api.api({
		url: "/jeecg-boot/api/adopt/goods/order/evaluate/"+param.goodId,
		// method: "POST",
		data: param
	})
	return data
}
export {
	goods,
	goodsInfo,
	cart,
	addCart,
	updateCart,
	deleteCart,
	pay,
	immediately,
	repeat,
	orderList,
	orderDetail,
	cancelReasons,
	orderCancel,
	evaluate,
	evaluateId
}